<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="icon" href="/images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
    <title>防骚扰 - 模拟测试</title>
</head>
<body>
<% include ../top/admin_top.ejs %>
<div class="layui-container" style="text-align: center; margin: 20px">
    <div class="layui-col-md3">
        <div class="layui-row" style="padding: 5px; margin-top: 45px; text-align: left">
            <div style="font-weight: bold; font-size: 16px">主叫号码: 188xxxxxxxx</div>
            <div style="font-weight: bold;  font-size: 16px">被叫号码: 139xxxxxxxx</div>
        </div>
        <div class="layui-row" style="padding: 10px">
            <button type="button" style="font-weight: lighter;" class="layui-btn layui-btn-radius layui-btn-fluid" id="sim_call_btn">模拟拨打</button>
        </div>
        <div class="layui-row" style="padding: 10px">
            <button type="button" style="font-weight: lighter;" class="layui-btn layui-btn-radius layui-btn-fluid" id="sim_auth_btn">模拟授信</button>
        </div>
        <div class="layui-row" style="padding: 10px">
            <button type="button" style="font-weight: lighter;" class="layui-btn layui-btn-radius layui-btn-fluid" id="sim_block_btn">模拟拉黑</button>
        </div>
        <div class="layui-row" style="padding: 10px">
            <button type="button" style="font-weight: lighter;" class="layui-btn layui-btn-primary layui-border-red layui-btn-radius layui-btn-fluid" id="reset_btn">重 置</button>
        </div>

    </div>
    <div class="layui-col-md9">
        <% include ../details/baseModelDetails.ejs %>
    </div>
</div>
</body>
<script>
    layui.use('jquery', function () {
        let $ = layui.jquery;
        $('#head_name').html(localStorage.getItem('nickname'));
        $('#token_test_btn').on('click', function () {
            $.ajax({
                type: 'get',
                url: 'http://<%= server_host %>/test/tokenTest',
                headers: {token: localStorage.getItem('token')},
                dataType: 'json',
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg("TOKEN 测试通过")
                    } else {
                        console.log(res);
                    }
                },
            });
        });
        $('#config_btn').on('click', function () {
            window.location.href = '/base_config';
        });
        $('#sim_call_btn').on('click', function () {
            $.ajax({
                type: 'get',
                url: 'http://<%= server_host %>/simulator/phoneCall',
                headers: {token: localStorage.getItem('token')},
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.data + " 主叫 => 被叫")
                    } else {
                        console.log(res);
                    }
                },
            });
        });
        $('#sim_auth_btn').on('click', function () {
            $.ajax({
                type: 'get',
                url: 'http://<%= server_host %>/simulator/authorize',
                headers: {token: localStorage.getItem('token')},
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg("主叫加入被叫白名单")
                    } else {
                        console.log(res);
                    }
                },
            });
        });
        $('#sim_block_btn').on('click', function () {
            $.ajax({
                type: 'get',
                url: 'http://<%= server_host %>/simulator/block',
                headers: {token: localStorage.getItem('token')},
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg("主叫加入被叫黑名单")
                    } else {
                        console.log(res);
                    }
                },
            });
        });
        $('#reset_btn').on('click', function () {
            $.ajax({
                type: 'get',
                url: 'http://<%= server_host %>/simulator/reset',
                headers: {token: localStorage.getItem('token')},
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg("重置数据")
                    } else {
                        console.log(res);
                    }
                },
            });
        });
    });
</script>
</html>